package com.rui.study.commons.study.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.Enumeration;

public class GlobalListener implements ServletContextListener {

    private static final Logger LOGGER = LoggerFactory.getLogger(GlobalListener.class);

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        ServletContext context = servletContextEvent.getServletContext();
        Enumeration enumeration = context.getInitParameterNames();
        LOGGER.info("ContextInitParameter:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        while (enumeration.hasMoreElements()) {
            String name = (String) enumeration.nextElement();
            String value = context.getInitParameter(name);
            LOGGER.info("{} : {}", name, value);
        }
        LOGGER.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
